package nabaixin.com.net.protocol;

import android.content.Context;
import android.util.Log;
import nabaixin.com.utils.Constant;

public class LoginProtocol extends BaseProtocol {
	private static final String TAG = "LoginProtocol-->";
	
	private String email;
	private String password;
	private String btaddr;

	private String packedStr;
	private String encodeStr;
	
	public LoginProtocol(String email, String password, String btaddr) {
		this.email = email;
		this.password = password;
		this.btaddr = btaddr;
	}

	@Override
	public void packData() {
		// LOGIN [TRID] 100 email=xxxx&pwd=xxxx&btaddr=xxxx&ver=xxxx
		StringBuffer sb = new StringBuffer();
		sb.append("LOGIN ").append(Constant.TRID_LOGIN).append(" 100 ")
			.append("email=").append(email)
			.append("&pwd=").append(password)
			.append("&btaddr=").append(btaddr)
			.append("&ver=").append(Constant.VER);
		packedStr = sb.toString();
		Log.d(Constant.TAG, TAG+packedStr);
	}

	@Override
	public void excute(Context context) {
		encodeStr = encodeData(packedStr, TAG);
		sendData(context, encodeStr);
	}

}
